<extend name="Base:base" />
<block name="title"><title>门票管理</title></block>
<block name="content">

<script type="text/javascript" src="__PUBLIC__/Js/account_manage.js"></script>

<script type="text/javascript" src="__PUBLIC__/Js/jquery-1.9.1.min.js"></script>

<script type="text/javascript" src="__PUBLIC__/Js/jquery.fDialog.min.js"></script>

<script type="text/javascript" src="__PUBLIC__/Js/fDialog.plugin.js"></script>

<script type="text/javascript" src="__PUBLIC__/Js/ajaxfileupload.js"></script>
<link rel="stylesheet" href = "__PUBLIC__/Css/fDialog.css">
<link rel="stylesheet" href = "__PUBLIC__/Css/animate.css">
<link href = "__PUBLIC__/Css/index.css" type = "text/css" rel = "stylesheet"/>
	<div id="content" align="center">		
		<div id="user" >
			<p style="margin-left:-560px; font-size:20px; color:#1d353f; font-weight:bold;">门票列表</p>
			<div id='addBtn'><input type="button" value="添加门票" id="btn" onclick="javascript:window.location.href = '__CONTROLLER__/add';"></div>
			<hr width="700px"/>
			<table>
			<tr style="color:#1d353f;"><th>序号</th><th>门票名字</th><th>图片</th><th>原价</th><th>现价</th><th>景区</th><th>操作</th><tr>
			<foreach name="list" item="ticket">
			<tr>
				<td><if condition="($_GET['p'] eq 0)">{++$i}<else />{++$i + ($_GET['p']-1) * 7}</if></td>
				<td>{$ticket['name']}</td>
				<td style="height: 100px"><img id="nowimg" name="nowimg" style="height: 100px;width: 100px" src="{$ticket['image']}"></td>
				<td>{$ticket['original']}</td>
				<td>{$ticket['price']}</td>
				<td>{$ticket['scenic']}</td>
				<td>
				<a href="javascript:void(0)" onclick="javascript:test(this)" tid="{$ticket['id']}"><img  src="__PUBLIC__/Img/edit.png"/></a>
					<a href="javascript:userDelete('__CONTROLLER__/delete','{$ticket['id']}')">
					<img src="__PUBLIC__/Img/delete.png" /></a></td>
			</tr>
			</foreach>	
			</table>
		</div>	
		<div id="count" align="center">共{$count}条</div>	
		<div id="page" align="center">{$page}</div>	
	</div>
<script type="text/javascript">
var changeType = "{:U('ScenicTicket/change')}"; 
	function test(dom){
		var url = "{:U('ScenicTicket/edit',array('tid'=>'###'))}";
		var tid = dom.getAttribute('tid');
		url =url.replace("%23%23%23",tid);
 		$.fDialog({
			id : 'myTicketdialog',
			title : '编辑门票', //标题
			content : url,
			buttons : ['保存','取消'],
			buttonClick : function(v,b,i,$f,t){
				if(i==0){
					change ();
				}
				else{
				    return true;
				}
			},
			module : 'ajax',
			animated : 'zoomIn', //入场动画效果CSS样式
			removeAnimated : 'zoomOut', //退场动画效果CSS样式
			w : "350px", //宽
			h : "450px", //高
			borderWidth : '5px', //设置边框大小
			initEnd : function($obj){
  				$obj.find('.fdialog-html').css('overflow','hidden');
			}
		});
}
	function change (){
		var ticketname = $("#ticketName").val();
		var price      = $("#price").val();
		var original   = $("#original").val();
		var deadline   = $("#d").val(); 
		 $.ajaxFileUpload
  			(
                {
                    url: changeType, //用于文件上传的服务器端请求地址
                    type: 'post',
                    data: { ticketname:ticketname,price:price,original:original,deadline:deadline}, //此参数非常严谨，写错一个引号都不行
                    secureuri: false, //一般设置为false
                    fileElementId: 'newimg', //文件上传空间的id属性  <input type="file" id="file" name="file" />
                    dataType: 'json', //返回值类型 一般设置为json
                    success: function (data, status)  //服务器成功响应处理函数
                    {
                       setTimeout('$("#type_cg").html("保存成功")', 1000 );
                       window.location.reload();
                       //$.fDialog('remove',"myTicketdialog",true);

                    },
                    error: function (data, status, e)//服务器响应失败处理函数
                    {
                        setTimeout('$("#type_ts").html("保存失败")', 1000 );
                       // $.fDialog('remove',"myTicketdialog",true);
                    }
                }
            ) 	
		}
</script>

</block>
